<?php

/* * 
 * 资讯
 */
namespace Common\Model;
use Think\Model;
class MaterialModel extends BaseModel {

    public function queryForList($page=null, $map=null) {
        $list = $this->alias("m")
            ->join("left join __CODE__ c on c.code_id = m.code_id")
            ->join("left join __CODE__ p on p.code_id = c.parentid")
            ->where(getWhereSqlByMap($map))
            ->order("m.material_id asc")
            ->limit($page->firstRow . ',' . $page->listRows)
            ->field("m.*, c.name as code_name, p.name as parent_name")
            ->select();

        return $list;

    }

    public function getListCount($map = null) {

        $count = $this->alias("m")
            //->join("left join __CATEGORY__ c on c.category_id = p.category_id")
            ->where(getWhereSqlByMap($map))
            ->count();

        return $count;
    }

}

